<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('申请记录列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <input type="hidden" id="scienceId" name="scienceId" th:value="${scienceId}">
                    <input type="hidden" id="scienceLeaderId" name="scienceLeaderId" th:value="${scienceLeaderId}">
                    <input type="hidden" id="verifyType" name="verifyType" th:value="${verifyType}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>所在科室：</label>
                                <input type="text" name="deptName"/>
                            </li>
                            <li>
                                <label>申请人员：</label>
                                <input type="text" name="userName"/>
                            </li>
                            <li>
                                <label>人员类型：</label>
                                <select name="userType">
                                    <option value="">所有</option>
                                    <option value="1">普通职工</option>
                                    <option value="2">科级干部</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>申请时间： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning single disabled" onclick="verify()" shiro:hasPermission="record:verify:save">
                    <i class="fa fa-print"></i> 审批
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "record/society/verify";

        var verifyType = [[${verifyType}]];
        var sexs = [[${@dict.getType('sys_user_sex')}]];

        $(function() {
            var options = {
                url: prefix + "/list",
                modalName: "待审核记录",
                sortName: "createTime",
                sortOrder: "desc",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'societyId',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'userType',
                    title: '人员类型',
                    formatter: function(value, row, index) {
                        if(value == '01') {
                            return "普通职工";
                        }else {
                            return "科级干部";
                        }
                    }
                },
                {
                    field: 'userName',
                    title: '申请人'
                },
                {
                    field: 'sex',
                    title: '性别',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(sexs, value);
                    }
                },
                {
                    field: 'birthday',
                    title: '出生年月'
                },
                {
                    field: 'deptName',
                    title: '所在科室'
                },
                {
                    field: 'major',
                    title: '专业'
                },
                {
                    field: 'societyTitle',
                    title: '参加学会、协会名称'
                },
                {
                    field: 'startTime',
                    title: '开始时间'
                },
                {
                    field: 'endTime',
                    title: '截止时间'
                },
                {
                    title: '审批状态',
                    formatter: function(value, row, index) {
                        if(verifyType == 'science') {
                            if(row.scienceFlag == '0') {
                                return '<span class="label label-default">未审批</span>';
                            }else if(row.scienceFlag == '1') {
                                return '<span class="label label-success">审批同意</span>';
                            }else {
                                return '<span class="label label-warning">审批不同意</span>';
                            }
                        } else if(verifyType == 'scienceLeader') {
                            if(row.scienceLeaderFlag == '0') {
                                return '<span class="label label-default">未审批</span>';
                            }else if(row.scienceLeaderFlag == '1') {
                                return '<span class="label label-success">审批同意</span>';
                            }else {
                                return '<span class="label label-warning">审批不同意</span>';
                            }
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '申请时间'
                }]
            };
            $.table.init(options);
        });

        function verify(){
            var row = $("#bootstrap-table").bootstrapTable('getSelections')[0];
            var url = prefix + "/verify/" + row.societyId + "/" + $("#verifyType").val();
            $.modal.openFull("事项审批", url);
        }
    </script>
</body>
</html>